/*
 * Copyright (c) 2023, 2023,yzc.cn All rights reserved.
 *
 */
package cn.yzc.controller;

import cn.yzc.client.GoodsRemoteClient;
import cn.yzc.pojo.Good;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>Project: SpringColud - OrderController</p>
 * <p>Powered by yzc On 2023-12-29 14:56:24</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */
@RestController
public class OrderController {

    @Autowired
    GoodsRemoteClient goodsRemoteClient;

    /**
     * 查询订单
     * @return
     */
    @GetMapping("/order")
    public Map save(){
        System.out.println("查询订单");
        //更新库存
        Map tmp = goodsRemoteClient.get("001");
        Map map = new HashMap<>();
        map.put("code",200);
        map.put("msg","查询订单成功");
        map.put("stock",tmp);
    return map;
    }

    @GetMapping ("/queryPage")
    public Map query(){
        Map query = goodsRemoteClient.query(4, 10, "李四");
        Map map = new HashMap<>();
        map.put("code",200);
        map.put("msg","请求成功");
        map.put("data",query);
        return map;
    }

    @GetMapping("/queryMap")
    public Map query2(){
        Map map = new HashMap<>();
        map.put("code",200);
        map.put("msg","请求成功");
        map.put("data","map多参请求");
        Map data =goodsRemoteClient.queryMap(map);
        return data;
    }

    @PostMapping("/queryGood")
    public Map query3(@RequestBody Good good){
        Map map = goodsRemoteClient.queryGood(good);
        return map;
    }

    @DeleteMapping("/ById/{id}")
    public Map query4(@PathVariable("id") int id){
        Map map = goodsRemoteClient.queryId(id);
        return map;
    }
}
